package com.shelpe.services.sinbad.controller.dto.page;

import java.util.List;

import com.fasterxml.jackson.annotation.JsonProperty;

import lombok.Data;

@Data
public class ListMybatisPage<T> {

	private List<T> content;
	private int size;// 每页显示大小条数
	@JsonProperty("total_pages")
	private int totalPages;// 总页数
	@JsonProperty("total_elements")
	private int totalElements;// 总条数
	private int number;// 当前页
	@JsonProperty("number_of_elements")
	private int numberOfElements;// 当前页条数

	public void from(int page, int size, int sum, int contentSize) {
		this.size = size;
		this.totalPages = (sum % size == 0 ? sum / size : (int) Math.floor(sum / size) + 1);
		this.totalElements = sum;
		this.number = page;
		this.numberOfElements = contentSize;
	}
}
